import { splitToLength, BoolStrWithBoolen } from '../../Utils/common'
export function reviewChiefComplaint(data) {
  const {
    attr1,
    attr19,
    attr20,
    attr254,
    attr257,
    attr256,
    attr255,
    attr44,
    attr21,
    attr38,
    attr260,
    attr8,
  } = data
  if (!attr1) return ''
  let str = ''
  str += attr1Convert(attr1)
  str += attrPatrConvert(attr19, attr20, attr254, attr257, attr256, attr255)
  if (attr44) str += `过去4周睡眠过程中${attr44}曾经因为咳嗽、气喘醒来。`
  if (attr21) str += `过去4周需要使用药物缓解咳嗽/咳喘症状总有${attr21}次。`
  if (attr38)
    str += `孩子${attr38}在跑动或玩耍过程中因为咳嗽、气喘或气促被迫停下来。`
  if (attr260)
    str += `${BoolStrWithBoolen(attr260) ? '有' : '没有'}临时调整过治疗方案。`
  if (attr8) str += `其他：${attr8}。`
  return str
}

function attr1Convert(attr1 = '') {
  if (splitToLength(attr1, 2)) {
    return '上次就诊至今咳嗽伴喘息。'
  } else if (attr1) {
    const cough = attr1.includes('咳嗽') ? '有咳嗽' : '无咳嗽'
    const wheezing = attr1.includes('伴喘息') ? '有喘息' : '无喘息'
    return `上次就诊至今 ${cough}，${wheezing}。`
  }
  return ''
}

function attrPatrConvert(attr19, attr20, attr254, attr257, attr256, attr255) {
  let str = ''
  function attr19to20(attr19, attr20) {
    if (attr19 && attr20) {
      return `过去4周共有咳嗽${attr19}天，喘息发作${attr20}次，`
    } else if (attr19) {
      return `过去4周共咳嗽${attr19}天，`
    } else if (attr20) {
      return `过去4周喘息共发作${attr20}次，`
    }
    return ''
  }

  function attr253and257(attr254, attr257) {
    if (attr254 && attr257) {
      return `于${attr254}周${attr257}天前出现。`
    } else if (attr254) {
      return `于${attr254}周前出现。`
    } else if (attr257) {
      return `于${attr257}天前出现。`
    }
    return ''
  }
  str += attr19to20(attr19, attr20)
  if (str) {
    str += attr253and257(attr254, attr257)
    if (attr256) `症状持续时${attr256}天。`
    if (attr255) `无咳嗽喘息症状持续时间${attr256}天。`
  }
  return str
}
// 于1周2天前出现，长期控制治疗药物有调整。
